import { CSSProperties } from "react";

export function css_block(name: string, props: Partial<CSSProperties>) {
  let ret = `${name} {\n`;
  for (const key in props) {
    const name = key.replace(/([A-Z])/g, (a, b) => { return '-' + b.toLowerCase(); });
    const value = (props as any)[key];
    ret += `  ${name}: ${value};\n`;
  }
  ret += '}\n';
  return ret;
};
export interface ICSSBlocks {
  [x: string]: Partial<CSSProperties>
}
export function css_blocks(map: ICSSBlocks) {
  let ret = ''
  for (const key in map) {
    ret += css_block(key, map[key])
  }
  return ret;
}